import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { ObjCreate } from "../common/ObjCreate";
import { ToolTipItem } from "../../../../com/mui/manager/ToolTipItem";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { StringHelper } from "../../../../com/gengine/utils/StringHelper";
import { MsgManager } from "../../manager/MsgManager";
import { GameRMI } from "../../net/rmi/GameRMI";
import { AMI_IActive_useMeidaCard } from "../../../../Message/Game/AMI_IActive_useMeidaCard";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { GButton } from "../../../../com/mui/controls/GButton";
//class MeidaCardWindow
    
    export  class MeidaCardWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(313, 263);
            titleHeight = 26;
            title = "禮品兌換";
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(19, 40, 279, 166, this);
            this._spProp = new ToolTipItem();
            this._spProp.toolTipData = "<font color=\'#FFFFFF\'>禮品卡禮包，輸入序列號即可領取</font>";
            ObjCreate.setObjAttri(this._spProp, 123, 49, -1, -1, this);
            var loc1=GlobalClass.getBitmap("PropBg");
            this._spProp.addChild(loc1);
            var loc2=new Object /* flash.display.Bitmap */();
            LoaderHelp.setBitmapdata("14011484.jpg", loc2, 5, 5, 60, 60);
            this._spProp.addChild(loc2);
            ObjCreate.createTextField("輸入序列號：", 27, 117, 120, 20, this, GlobalStyle.textFormat2);
            this._tiMeidaCard = ObjCreate.createGTextInput(30, 140, 240, 20, this);
            this._btnGet = ObjCreate.createGButton("領取", 132, 169, 50, 22, this, "ButtonSpecial");
            var loc3=ObjCreate.createTextField("", 23, 216, 270, 40, this);
            loc3.wordWrap = true;
            loc3.multiline = true;
            loc3.htmlText = "<textFormat leading = \'6\'><font color=\'#00FF00\'>温馨提示：</font>輸入<font color=\'#F1FFB1\'>序列號</font>，點擊領取即可獲得<font color=\'#FF00FF\'>豐富獎勵</font>，<font color=\'#00FF00\'>每個序列號只能領取一次</font></textFormat>";
            this._btnGet.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnGetClick);
            return;
        }

        /* internal  */onBtnGetClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._tiMeidaCard.text;
            loc1 = StringHelper.trim(loc1);
            if (loc1.length < 10) 
            {
                MsgManager.showRollTipsMsg("媒體推廣卡長度不夠10位");
                return;
            }
            if (loc1.length > 100) 
            {
                MsgManager.showRollTipsMsg("媒體推廣卡長度超過100位");
                return;
            }
            GameRMI.instance.iActive.useMeidaCard_async(new AMI_IActive_useMeidaCard(), loc1);
            return;
        }

        public static get instace(): MeidaCardWindow
        {
            if (!MeidaCardWindow._instance) 
            {
                MeidaCardWindow._instance = new MeidaCardWindow();
            }
            return MeidaCardWindow._instance;
        }

        /* internal */ /* var */_spProp: ToolTipItem;

        /* internal */ /* var */_tiMeidaCard: GTextInput;

        /* internal */ /* var */_btnGet: GButton;

        /* internal */ static /* var */_instance: MeidaCardWindow;
    }
